package com.wenzi.rule.verification.form;

import org.springframework.expression.spel.support.StandardEvaluationContext;

import java.util.HashMap;
import java.util.Map;

public class Form {
    private Object root;

    private Map<String,Object> objects = new HashMap<>();

    public Form(Object root) {
        this.root = root;
    }

    public void setObjects(String key,Object value){
        objects.put(key,value);
    }

    public void setVariableFor(StandardEvaluationContext context){
        context.setRootObject(root);
        objects.forEach(context::setVariable);
    }

    @Override
    public String toString() {
        return root.getClass().getSimpleName();
    }
}
